<?php
/**
 * Created by PhpStorm.
 * User: czw
 * Date: 2018/7/11
 * Time: 14:59
 */
namespace app\common\model;


use app\lib\exception\BaseException;

class Page extends BaseModel
{
    protected $hidden = ['create_time','update_time','delete_time'];
    public function getImgUrlAttr($value){
        return config('common.img_url').$value;
    }
    public static function getAll(){
        return self::select();
    }
    public static function updateOne($id,$data){
        //转化成整形
//        if(isset($data['use_main_img'])){
//            $data['use_main_img'] = (bool)$data['use_main_img'];
//        }
        $model = new self();
        $res = $model->save($data,['id'=>$id]);
        if(!$res) throw new BaseException(['msg'=>'修改失败或无修改！']);
        return $model;
    }
}